package util;

import org.junit.Assert;

import java.util.Arrays;
import java.util.List;

public class AssertUtils extends Assert {
    public static <T> void assertListEquals(List<T> expected, List<T> actual) {
        if (expected == actual) return;
        if (expected == null || actual == null) {
            fail("有一个列表为空");
        }
        if (expected.size() != actual.size()) {
            fail("两个列表的长度不相同");
        }
        for (int i = 0; i < expected.size(); i++) {
            T o1 = expected.get(i);
            T o2 = actual.get(i);
            Assert.assertEquals(o1, o2);
        }
    }

    public static void main(String[] args) {
        List<Integer> list1 = Arrays.asList(1, 2, 3);
        List<Integer> list2 = Arrays.asList(1, 2, 3);
        assertListEquals(list1, list2);
    }
}
